package com.appbee.article.client.presenter;

import javax.inject.Inject;

import com.appbee.article.client.ui.ArticleBox;
import com.appbee.cm.client.regionunit.presenter.HasActivityEntry;
import com.appbee.cm.shared.data.ActivityEntryProxy;
import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.AcceptsOneWidget;

public class ArticleActivity extends AbstractActivity implements
		HasActivityEntry
{
	private final ArticleBoxProvider articleBoxProvider;
	private ActivityEntryProxy activityEntry;

	@Inject
	public ArticleActivity(ArticleBoxProvider articleBoxProvider)
	{
		this.articleBoxProvider = articleBoxProvider;
	}

	@Override
	public void start(AcceptsOneWidget panel, EventBus eventBus)
	{
		ArticleSettings settings = new ArticleSettings(
				activityEntry.getSettings());
		ArticleBox articleBox = articleBoxProvider.getByStrId(settings
				.getArticleId());
		panel.setWidget(articleBox);
	}

	@Override
	public void setActivityEntry(ActivityEntryProxy activityEntry)
	{
		this.activityEntry = activityEntry;
	}

}
